<template>
  <!-- 访问来源 -->
  <div ref="main" style="width: 100%; height: 300px"></div>
</template>

<script>
import * as echarts from 'echarts';
export default {
  mounted() {
    var myChart = echarts.init(this.$refs.main);
    const option = {
      tooltip: {
        trigger: 'item',
      },
      legend: {
        bottom: '-5px',
        left: 'center',
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: ['40%', '70%'],
          avoidLabelOverlap: false,
          itemStyle: {
            borderRadius: 10,
            borderColor: '#fff',
            borderWidth: 2,
          },
          label: {
            show: false,
            position: 'center',
          },
          emphasis: {
            label: {
              show: true,
              fontSize: '40',
              fontWeight: 'bold',
            },
          },
          labelLine: {
            show: false,
          },
          data: [
            { value: 1048, name: '搜索引擎' },
            { value: 580, name: '直接访问' },
            { value: 484, name: '邮件营销' },
            { value: 300, name: '联盟广告' },
          ],
        },
      ],
    };
    option && myChart.setOption(option);
  },
};
</script>

<style></style>
